package org.xxpay.pay.channel.saaspay;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * Saas支付
 * @author: Zhixin
 * @date: 2020年2月28日09:07:38
 */
@Component
public class SaaspayConfig {

    public static final String CHANNEL_NAME = "saaspay";

    public static final String CHANNEL_NAME_H5PAY = CHANNEL_NAME + "_h5pay";
    public static final String CHANNEL_NAME_WEBPAY = CHANNEL_NAME + "_webpay";
    public static final String CHANNEL_NAME_MINIPAY = CHANNEL_NAME + "_minipay";

    public static final String RETURN_VALUE_SUCCESS = "SUCCESS";
    public static final String RETURN_VALUE_ERROR = "FAILED";
    public static final String SYSTEM_ORDER_CODE = "386B";//银联商务分配的系统编号（作为订单号前4位）

    // 终端号
    private String tid;
    // 商户账号
    private String mid;
    // appId
    private String appId;
    // appKey
    private String appKey;
    // 通讯密钥
    private String key;
    // 请求地址
    private String reqUrl;
    // 业务类型
    private String instMid;
    //支付类型
    private String payType;

    public SaaspayConfig(){}

    public SaaspayConfig(String payParam) {
        Assert.notNull(payParam, "init "+ CHANNEL_NAME +" config error");
        JSONObject object = JSONObject.parseObject(payParam);
        this.tid = object.getString("tid");
        this.mid = object.getString("mid");
        this.appId = object.getString("appId");
        this.appKey = object.getString("appKey");
        this.key = object.getString("key");
        this.reqUrl = object.getString("reqUrl");
        this.instMid = object.getString("instMid");
        this.payType = object.getString("payType");
    }

    public String getTid() {
        return tid;
    }

    public void setTid(String tid) {
        this.tid = tid;
    }

    public String getMid() {
        return mid;
    }

    public void setMid(String mid) {
        this.mid = mid;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppKey() {
        return appKey;
    }

    public void setAppKey(String appKey) {
        this.appKey = appKey;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getReqUrl() {
        return reqUrl;
    }

    public void setReqUrl(String reqUrl) {
        this.reqUrl = reqUrl;
    }

    public String getInstMid() {
        return instMid;
    }

    public void setInstMid(String instMid) {
        this.instMid = instMid;
    }

    public String getPayType() {
        return payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }
}
